<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    <button @click="addLi">增加li</button>
    <ul>
      <li v-for="(item,index) in arr" :key="index">
        {{ item }}
      </li>
    </ul>
  </div>
  <script src="./vue.js"></script>
  <script>
    const  vm = new Vue({
      el: '#app',
      data: {
        arr: [1,2,3,4]
      },
      methods: {
        addLi(){
          this.arr.push(this.arr.length+1)
          // 获取ul
          const oul = document.querySelector('ul');
          // oul.lastElementChild.style.background = 'red'; 
          this.$nextTick(() => {
            // 订阅时每一次数据修改 视图更新完成
            console.log(oul.children, 222);
            oul.lastElementChild.style.background = 'red'; 
          })
          console.log(oul.children, 111);
        }
      }
    })
  </script>
</body>
</html>